package interfaces;

import java.util.ArrayList;

/**
 * @author chihb
 * @create-time 2024/6/28 21:32
 * @description
 */
public class StudentOpImpl2 implements StudentOpearter{
    @Override
    public void printAllINfo(ArrayList<Student> students) {
        System.out.println("==========打印全部的学生对象==========");
        int count1=0;
        int count2=0;
        for(int i=0;i<students.size();i++){
            Student s=students.get(i);
            System.out.println("姓名："+s.getName()+",性别："+s.getSex()+",成绩："+s.getScore());
            if(s.getSex()=='男'){
                count1++;
            }else {
                count2++;
            }

        }
    }

    @Override
    public void printScore(ArrayList<Student> students) {
        System.out.println("==========打印全部的学生对象==========");
        Double sum=0.0;
        Double max=students.get(0).getScore();
        Double min=students.get(0).getScore();
        for(int i=0;i<students.size();i++){
            Student s=students.get(i);
            sum+=s.getScore();
            if(min>s.getScore()) min=s.getScore();
            if(max<s.getScore()) max=s.getScore();
        }
        System.out.println("平均成绩为:"+(sum-max-min)/(students.size()-2));
    }
}
